//package com.gongj.secuity.config;
//
//import java.io.IOException;
//import java.io.PrintWriter;
//import java.util.HashMap;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.annotation.Order;
//import org.springframework.security.authentication.AccountExpiredException;
//import org.springframework.security.authentication.BadCredentialsException;
//import org.springframework.security.authentication.CredentialsExpiredException;
//import org.springframework.security.authentication.DisabledException;
//import org.springframework.security.authentication.LockedException;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.authentication.AuthenticationFailureHandler;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//
////@Configuration
//public class MultiSecurityConfig {
//
//	@Bean
//    PasswordEncoder passwordEncoder() {
//        return new BCryptPasswordEncoder();
//    }
//	
//	@Autowired
//	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//		auth.inMemoryAuthentication()
//		.withUser("yuan").password("$2a$10$LOjNzkgnjz81FxVYV9L51uXaHi.6xWK/aKbGwr9qAwZ6c/3QuVPk2")
//		.roles("admin")  //199842
//		.and()
//		.withUser("gong").password("$2a$10$M/wPgxmOnW03CNz/kr8KFuo1qyWDK51g0GOsH2G4vBO0bH.au2OdW")
//		.roles("user");  //199919
//	}
//	
//	
//	@Configuration
//	@Order(1)  //优先级 数值越小优先级越大
//	public static class adminSecurityConfig extends WebSecurityConfigurerAdapter{
//		@Override
//		protected void configure(HttpSecurity http) throws Exception {
//			http.antMatcher("/admin/**").authorizeRequests().anyRequest().hasRole("admin");
//		}
//		
//	}
//	
//	@Configuration
//	@Order(2)  //优先级 数值越小优先级越大
//	public static class userSecurityConfig extends WebSecurityConfigurerAdapter{
//		@Override
//		protected void configure(HttpSecurity http) throws Exception {
//			http.antMatcher("/user/**").authorizeRequests().anyRequest().hasRole("user");
//		}
//		
//	}
//	@Configuration
//	public static class otherSecurityConfig extends WebSecurityConfigurerAdapter{
//		@Override
//		protected void configure(HttpSecurity http) throws Exception {
//			http.authorizeRequests()
//			.anyRequest().authenticated()
//			.and()
//			.formLogin()
//			.loginProcessingUrl("/doLogin")
//			.permitAll()//开启表单登录并配置登录接口
//			.and()
//			.csrf().disable();  // 关闭csrf
//		}
//	}
//}
